// pages/department/department.js

const app = getApp();

Page({
  data: {
    keyword: "",
    active: 2,
    tabbarList: app.globalData.tabbarList,

    department: [
      {
        "typeId": 0,
        "icon": "/icon/bone.svg",
        "text": "骨科",
        "type": "bone"
      },
      {
        "typeId": 1,
        "icon": "/icon/brain.svg",
        "text": "心理科",
        "type": "brain"
      },
      {
        "typeId": 2,
        "icon": "/icon/ear.svg",
        "text": "耳科",
        "type": "ear"
      },
      {
        "typeId": 3,
        "icon": "/icon/throat.svg",
        "text": "咽喉科",
        "type": "throat"
      },
      {
        "itypeId": 4,
        "icon": "/icon/heart.svg",
        "text": "心血管科",
        "type": "heart"
      },
      {
        "typeId": 5,
        "icon": "/icon/kidney.svg",
        "text": "泌尿科",
        "type": "kidney"
      },
      {
        "typeId": 6,
        "icon": "/icon/lung.svg",
        "text": "呼吸科",
        "type": "lung"
      },
      {
        "typeId": 7,
        "icon": "/icon/stomach.svg",
        "text": "消化科",
        "type": "stomach"
      },
      {
        "itypeIdd": 8,
        "icon": "/icon/teeth.svg",
        "text": "口腔科",
        "type": "teeth"
      },
      {
        "typeId": 9,
        "icon": "/icon/child.svg",
        "text": "儿科",
        "type": "child"
      },
      {
        "typeId": 10,
        "icon": "/icon/woman.svg",
        "text": "妇科",
        "type": "woman"
      },
      {
        "typeId": 11,
        "icon": "/icon/nerve.svg",
        "text": "神经科",
        "type": "nerve"
      },
    ]
  },

  onClickDoctorType(event) {
    console.log("onClickDoctorType", event);

    let doctorType = event.currentTarget.dataset.item;
    console.log("type: ", doctorType);

    wx.navigateTo({
      url: '/pages/department/doctorList/doctorList?doctorType=' + encodeURIComponent(JSON.stringify(doctorType))
    });
  },

  onClickTabbar(event) {
    console.log("onClickTabbar", event);
    const url = this.data.tabbarList[event.detail].url;

    wx.switchTab({
      url: url,
    });
  },
  
  onSearch() {
    wx.navigateTo({
      url: '/pages/doctorList/search/search?keyword=' + this.data.keyword
    })
  },

  // 生命周期函数--监听页面初次渲染完成
  onLoad(options) {
    
  },

  // 生命周期函数--监听页面初次渲染完成
  onReady() { },

  // 生命周期函数--监听页面显示
  onShow() { },

  // 生命周期函数--监听页面隐藏
  onHide() { },

  // 生命周期函数--监听页面卸载
  onUnload() { },

  // 页面相关事件处理函数--监听用户下拉动作
  onPullDownRefresh() { },

  // 页面上拉触底事件的处理函数
  onReachBottom() { },

  // 用户点击右上角分享
  onShareAppMessage() { }
})